package org.jks.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "model")
public class Model {
	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@Column(name = "id")
	private long id;
	@Column(name = "name", length = 64, nullable = false)
	private String name;
	@Column(name = "desp", length = 512, nullable = false)
	private String desp;
	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinTable(name = "model_privilege", joinColumns = @JoinColumn(name = "model_id"), inverseJoinColumns = @JoinColumn(name = "privilege_id"))
	private Set<Privilege> privilege = new HashSet<Privilege>();
	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "model")
	private Set<Group> group = new HashSet<Group>();

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesp() {
		return desp;
	}

	public void setDesp(String desp) {
		this.desp = desp;
	}

	public Set<Privilege> getPrivilege() {
		return privilege;
	}

	public void setPrivilege(Set<Privilege> privilege) {
		this.privilege = privilege;
	}

	public Set<Group> getGroup() {
		return group;
	}

	public void setGroup(Set<Group> group) {
		this.group = group;
	}

}
